api key issue

by: stephenseangleason, 7 years ago



import quandl
import pandas as pd

api_key = open('qevSMqq_UjPzHaAQPNxt','r').read()
#quandl.ApiConfig.api_key = "qevSMqq_UjPzHaAQPNxt"
#mydata = quandl.get("FRED/GDP")


main_df = pd.DataFrame()
              

fiddy_states = pd.read_html('https://simple.wikipedia.org/wiki/List_of_U.S._states')

for abbv in fiddy_states[0][0][1:]:
    query= "FMAC/API_"+str(abbv)
    df = quandl.get(query, authtoken=api_key)  

    if main_df.empty:
        main_df = df

    else:
        main_df = main_df.join(df)

print(main_df.head)


Then I get an error message like so
Traceback (most recent call last):
  File "C:UsersstephenAppDataLocalProgramsPythonPython35ng.py", line 5, in <module>
    api_key = open('qevSMqq_UjPzHaAQPNxt','r').read()
FileNotFoundError: [Errno 2] No such file or directory: 'qevSMqq_UjPzHaAQPNxt'




I also tried making text file in working directory with api_key in it. Please let me know what Im doing wrong. thanks



You must be logged in to post. Please login or register an account.



Looks like you forgot the .txt part, like you forgot the period.

-Harrison 7 years ago

You must be logged in to post. Please login or register an account.